/*
*	ID : Pallab
* 	PROG : D
* 	LANG : C++
* 	2012-12-14-11.19.03 Friday
*
* 	"I have not failed, I have just found 10000 ways that won't work.
*/
#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <fstream>
#include <string>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <numeric>
#include <stack>
#include <functional>
#include <bitset>
#include <iomanip>
#include <chrono>
#include <unordered_set>
#include <unordered_map>
#include <array>

#include <ctime>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <climits>
#include <cstring>
#include <cstdlib>

using namespace std;

#define foR(i1,st,ed) for(int i1 = st , j1 = ed ; i1 < j1 ; ++i1 )
#define fo(i1,ed) foR( i1 , 0 , ed )
#define foE(i1,st,ed) foR( i1, st, ed+1 )
#define foit(i, x) for (typeof((x).begin()) i = (x).begin(); i != (x).end(); i++)
#define bip system("pause")
#define Int long long
#define pb push_back
#define SZ(X) (int)(X).size()
#define LN(X) (int)(X).length()
#define mk make_pair
#define SET( ARRAY , VALUE ) memset( ARRAY , VALUE , sizeof(ARRAY) )
#define line puts("")

inline void wait(double seconds) {
    double endtime = clock() + (seconds * CLOCKS_PER_SEC);
    while (clock() < endtime) {
        ;
    }
}
struct encoder {
    int RR,CC;
    encoder() {
        RR=CC=0;
    }
    inline void Set(int RR_,int CC_) {
        RR=RR_,CC=CC_;
    }
    inline int encodePos(int rpos, int cpos) {
        return rpos*CC + cpos ;
    }
    inline int decodeR(int rpos) {
        return rpos/CC;
    }
    inline int decodeC(int cpos) {
        return cpos%CC;
    }
    inline void print(int pos) {
        cout<<decodeR(pos)<<' '<<decodeC(pos)<<'\n';
    }
} EN;
template<class T>
inline T fastIn() {
    register char c=0;
    register T a=0;
    bool neg=false;
    while(c<33)c=getchar();
    while(c>33) {
        if(c=='-') {
            neg=true;
        } else {
            a= (a*10)+(c-'0');
        }
        c=getchar();
    }
    return neg?-a:a;
}
const int MX=1005;
char G[MX][MX];
int R,C,D;
int rats[MX*MX];
int rats_count;
inline void read() {
    R=fastIn<int>(),C=fastIn<int>(),D=fastIn<int>();
    EN.Set(R,C);
    rats_count=0;
    fo(i,R) {
        fo(j,C) {
            G[i][j]=getchar();
            if(G[i][j]=='R')rats[rats_count++]= EN.encodePos(i,j);
        }
        getchar();
    }
}
const int rr[]= {-1,+1,+0,+0, -1,-1,+1,+1};
const int cc[]= {+0,+0,-1,+1, -1,+1,+1,-1};
unordered_set<int> adj[MX*MX];
bool seen[MX*MX];
inline void bfs1(int pos) {
    queue<pair<int,int> >q;
    SET(seen,false);

    q.push( mk(pos,D));
    seen[pos]=true;
    adj[pos].insert(pos);
    while(q.empty()==false) {
        int f=q.front().first,d=q.front().second;
        q.pop();

        int fr=EN.decodeR(f),fc=EN.decodeC(f);
        fo(i,4) {
            int tr=fr+rr[i],tc=fc+cc[i],tpos=EN.encodePos(tr,tc);
            if(tr<0||tc<0||tr>=R||tc>=C)continue;
            if(seen[tpos]||G[tr][tc]=='X' || d==0)continue;
            adj[pos].insert(tpos);
            seen[tpos]=true;
            q.push( mk(tpos,d-1));
        }
    }
}

inline unordered_set<int> get_rats(int pos){
    unordered_set<int> tmp;
    for(int i=0;i<rats_count;++i){
        if( adj[ rats[i] ].count(pos)<1 ){
            tmp.insert( rats[i] );
        }
    }return tmp;
}
inline bool can_kill_all(int pos, unordered_set<int>& lst){
    for(auto &x:lst){
        if( adj[x].count(pos)<1 )return false;
    }return true;
}
inline void proc() {
    if(rats_count>300) {
        puts("-1");
        return ;
    }
    fo(i,rats_count) {
        bfs1(rats[i]);
    }

    //first rats theke jekhane jekhane jauya jay sei guler upor bfs charbo

    for(auto &x: adj[rats[0]]){
        unordered_set<int> cant_kill = get_rats( x );
        if( cant_kill.empty() ){
            //can kill all of them
            cout<<EN.decodeR(x)+1<<' '<<EN.decodeC(x)+1<<' ';
            fo(i,R)fo(j,C){
                if(G[i][j]!='X'&& EN.encodePos(i,j)!=x){
                    cout<<i+1<<' '<<j+1<<'\n';
                    return ;
                }
            }
            return ;
        }else{
            for(auto &xx:cant_kill ){
                unordered_set<int> cango = adj[xx];
                for(auto &xxx:adj[xx]){
                    if( can_kill_all(xxx, cant_kill) ){
                        cout<<EN.decodeR(x)+1<<' '<<EN.decodeC(x)+1<<' ';
                        cout<<EN.decodeR(xxx)+1<<' '<<EN.decodeC(xxx)+1<<'\n';
                        return ;
                    }else{
                        ;
                    }
                }
            }
        }
    }
    puts("-1");
}
int main() {
    int kase = 1;
#if defined( xerxes_pc )
    if (!freopen("in1", "r", stdin))
        puts("error opening file in "), assert(0);
    kase = 1;
#else
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
    fo(i,kase) {
        read();
        proc();
    }
    return 0;
}
